package com.mrd.frame.onlinepay;

import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;

import com.mrd.frame.domain.NoticeMessage;
import com.mrd.weixinpay.util.HttpUtil;

@Component
public class PayNotice {
	private Logger logger = Logger.getLogger(PayNotice.class);
	
	/**
	 * 从新发送异步通知请求
	 * @author han
	 * @param noticeMessage
	 * @return
	 */
	public boolean excute(NoticeMessage noticeMessage){
		boolean result = false;
		String rtnBody = HttpUtil.postData(
				noticeMessage.getNotifyUrl(),
				noticeMessage.noticeMessageToJson().toString(), "application/json");
		logger.info("从发回掉通知客户端"+noticeMessage.toString());
		if ("SUCCESS".equals(StringUtils.trim(rtnBody))) {
			result = true;
		}
		logger.info("通知客户端返回："+rtnBody);
		return result;
	}
	
}
